package logic

import (
	"context"
	"mall_srv/goodclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsListLogic {
	return &GoodsListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GoodsListLogic) GoodsList(req *types.GoodsListrequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.GoodSrv.GoodsList(l.ctx, &goodclient.GoodsListRequest{})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Data: nil,
			Code: 500,
		}, nil
	}

	return &types.Response{
		Msg:  "商品查询成功",
		Data: list,
		Code: 200,
	}, nil
}
